fix: unwrap single non-object array items in allOf#23838
Conversation
There was a problem hiding this comment.
2 issues found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
@RomiRand could you move the code to the OpenApiNormalizer? |
1a0451d to
ffaeff5
Compare
@jpfinne Oh sure didn't realize, it's a big project 😅 I gave it a shot, ptal. Gotten bigger than anticipated, thought it makes sense to integrate with the existing oneOf/anyOf handling.. Lmk if a bigger diff like this should be avoided, or if renaming |
|
@RomiRand renaming an existing rule name is not a good idea. SIMPLIFY_ONEOF_ANYOF is also enabled by default, so your normalization is applied by default. Breaking changes should be avoided as much as possible. Skipping the $ref does not seem necessary for arrays, especially with the default Is there a unit test for the sample in #23837? |
|
@jpfinne I see, I replaced it with a new rule option.
Yes, these properties are kept by the existing I also added a unit test for the new simplification - but that's slightly misleading, as the core issue isn't about normalization. Current main wouldn't break that test either. I mainly want to generate valid code that compiles, optimized schemas are secondary. My earlier test of the
Without it I'm getting a long list of errors when running tests. I'm not sure where and why my |
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java">
<violation number="1">
P2: `SIMPLIFY_ALLOF` is not default-enabled after the rule split, causing a default-behavior regression for allOf primitive cleanup</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| @@ -41,7 +41,7 @@ | |||
| import java.util.stream.Collectors; | |||
There was a problem hiding this comment.
P2: SIMPLIFY_ALLOF is not default-enabled after the rule split, causing a default-behavior regression for allOf primitive cleanup
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java, line 236:
<comment>`SIMPLIFY_ALLOF` is not default-enabled after the rule split, causing a default-behavior regression for allOf primitive cleanup</comment>
<file context>
@@ -227,7 +233,7 @@ public OpenAPINormalizer(OpenAPI openAPI, Map<String, String> inputRules) {
// rules that are default to true
- rules.put(SIMPLIFY_ONEOF_ANYOF_ALLOF, true);
+ rules.put(SIMPLIFY_ONEOF_ANYOF, true);
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
rules.put(SIMPLIFY_ONEOF_ANYOF_ENUM, true);
</file context>
Fixes #23837
This PR unwraps the entry of an
allOfcomposed schema, if it is the only (non-object) item.Summary by cubic
Normalizes
allOfby removingnullsub-schemas (settingnullable) and unwrapping a single sub-schema, and fixes arrayitemsnormalization. Skips simplification when$refis present. Resolves #23837.New Features
SIMPLIFY_ALLOF(opt-in) to simplifyallOfand clearallOfon primitive/boolean types in OAS 3.0; documented usage indocs/customization.md.Bug Fixes
itemsusing the normalized schema; updated tests and added a YAML spec coveringallOf(including single-schema enums).Written for commit df3e846. Summary will update on new commits.